bin=httpserver
cc=g++
LD_FLAGS=-std=c++11 -lpthread
src=main.cc
curr=$(shell pwd)

.PHONY:all
all:$(bin) CGI

$(bin):$(src)
	$(cc) -o $@ $^ $(LD_FLAGS)

CGI:
	cd $(curr)/cgi;make;cd -;

.PHONY:clean
clean:
	rm -rf $(bin)
	rm -rf output
	cd $(curr)/cgi;make clean;cd -;
	
.PHONY:output
output:
	mkdir -p output
	cp -rf $(bin) output/
	cp -rf ./wwwroot output/
	cp ./cgi/test_cgi output/wwwroot/